print (imath.version)
local version in imath print (version)
big = $ (small) or big = $ (string, [base])
local $ in imath print ($ (0xa)) --> 10 print ($ "9999999999999999999999") --> 9999999999999999999999 print ($ ("100", 2)) --> 4
print ($5 == 5, type (5), type ($5)) --> false, int32, integer
local compare in imath print (compare ($5, 5)) --> 0
print (2^31) --> -2147483648
print ($2^31) --> 2147483648
print ($2^($2^10)) --> 179769313486231590772930519078902473361797697894230657273430081157732675805500 963132708477322407536021120113879871393357658789768814416622492847430639474124 377767893424865485276302219601246094119453082952085005768838150682342462881473 913110540827237163350510684586298239947245938479716304835356329624224137216
Note that if a function, say f, in the imath library has for its first argument, x, a big number then
imath.f (x, ... )
x:f (...)
$5:compare (5)
The standard operators of arithmetic
+ - * / % ^
| & ~
<< >>
The function imath.tostring converts big numbers to strings and the function imath.tonumber converts big numbers to small, or gives an error if not possible, thus being a sort of inverse to imath.$.
Another pair of functions imath.text and imath.totext convert from/to nonempty strings to/from big numbers. These functions are useful in cryptography.
The function imath.root takes a big number for its first argument and a small, say n for its second. It returns the least big number not less than the n-th root of the first argument.
The function imath.bits returns as a small number the number of bits in the binary expression for its big number argument.
The function imath.quotrem returns two big number values, the quotient and remainder from its two big number arguments, the dividend and the divisor.
The function imath.egcd returns three big number arguments
h, a, b = imath.egcd (x, y)
h == a*x + b*y
Note that long doublequoted strings can be split up by using the escape sequence \z.
local x = "aaaaaaaaaaaaaaaa\z bbbbbbbbbb" print (x) --> aaaaaaaaaaaaaaaabbbbbbbbbb